<?php

class FileProcessorController extends Controller
{
    public function initialise() {}
    
    public function UploadFiles($args=null)
    {
        $uploadDir = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "controllers") -1) . '/img/uploads/';
        $uploadFile = $uploadDir . basename($_FILES['Filedata']['name']);

        if ($args[0] == 1) {                
            if ($_FILES['Filedata']['name']) {
                if (move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadFile)) {
                    // delete the file
                    return $uploadFile;
                }
            } else {
                if ($_FILES['Filedata']['error']) {
                    return $_FILES['Filedata']['error'];
                }
            }
        }
    }
}
?>